<template>
  <div class="user-container">
    <el-card>
      <template #header>
        <div class="card-header">
          <h3>{{ $t('user.title') }}</h3>
        </div>
      </template>
      <el-table :data="userList" border style="width: 100%">
        <el-table-column prop="name" :label="$t('user.name')" />
        <el-table-column prop="role" :label="$t('user.role')" />
        <el-table-column prop="status" :label="$t('user.status')">
          <template #default="scope">
            <el-tag :type="scope.row.status === 'active' ? 'success' : 'danger'">
              {{ scope.row.status === 'active' ? '启用' : '禁用' }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column :label="$t('user.operation')" width="180">
          <template #default="scope">
            <el-button size="small" @click="handleEdit(scope.row)">编辑</el-button>
            <el-button size="small" type="danger" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'

// 模拟用户数据
const userList = ref([
  { id: 1, name: '管理员', role: '超级管理员', status: 'active' },
  { id: 2, name: '张三', role: '普通用户', status: 'active' },
  { id: 3, name: '李四', role: '普通用户', status: 'inactive' },
  { id: 4, name: '王五', role: '普通用户', status: 'active' }
])

const handleEdit = (row) => {
  console.log('编辑用户', row)
}

const handleDelete = (row) => {
  console.log('删除用户', row)
}
</script>

<style scoped>
.user-container {
  padding: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>